Read a file and store lines into a listΒΆ

Read a file line by line and store it into a list.
def file_read(fname):
    with open(fname) as f:
        #Content_list is the list that contains the read lines.
        L = f.readlines()
        print(L)

# test
file_read('test.txt')

Output:

['Welcome to w3resource.com.\n', 'Append this text.Append this text.Append this text.\n', 'Append this text.\n
', 'Append this text.\n', 'Append this text.\n', 'Append this text.\n']